﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using nvn.Library.Patterns;

namespace Hutech.CRM.Web.Page
{
    public partial class QuanLyDanhMucThongTin : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetVisibleFalseALL();
                ListLoaiDanhMucControl1.Visible = true;
            }
            

        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ListLoaiDanhMucControl1.ReloadData += new EventHandler<OneParameterEventAgrs<string>>(ListLoaiDanhMucControl1_ReloadData);
            ListDanhMucControl1.ReloadData += new EventHandler<OneParameterEventAgrs<string>>(ListDanhMucControl1_ReloadData);
            AddNewDanhMucControl1.ReloadData += new EventHandler<OneParameterEventAgrs<string>>(AddNewDanhMucControl1_ReloadData);
            AddNewLoaiDanhMucControl1.ReloadData += new EventHandler<OneParameterEventAgrs<string>>(AddNewLoaiDanhMucControl1_ReloadData);
        }

        void AddNewLoaiDanhMucControl1_ReloadData(object sender, OneParameterEventAgrs<string> e)
        {
            switch (e.myType)
            {
                case "CancelCommand":
                    SetVisibleFalseALL();
                    ListLoaiDanhMucControl1.Visible = true;
                    break;
                case "EnableCommand":
                    ListLoaiDanhMucControl1.Show();
                    break;
                case "ReloadCommand":
                    //UpdatePanelListLoaiDanhMucControl.Update();
                    //UpdatePanelAddNewLoaiDanhMucControl.Update();
                    break;
            }
        }

        void AddNewDanhMucControl1_ReloadData(object sender, OneParameterEventAgrs<string> e)
        {
            switch (e.myType)
            {
                case "CancelCommand":
                    SetVisibleFalseALL();
                    ListLoaiDanhMucControl1.Visible = true;
                    ListDanhMucControl1.Visible = true;
                    //UpdatePanelListLoaiDanhMucControl.Update();
                    break;
                case "EnableCommand":
                    ListDanhMucControl1.Show(AddNewDanhMucControl1.ObjecOnDelaga);
                    break;
                case "ReloadCommand":
                    //UpdatePanelListDanhMucControl.Update();
                    break;
            }
        }

        void ListDanhMucControl1_ReloadData(object sender, OneParameterEventAgrs<string> e)
        {
            //phai co dieu kien cho nay, luc nao them moi luc nao huy
            AddNewDanhMucControl1.Show(ListDanhMucControl1.ObjecOnDelaga);
            SetVisibleFalseALL();
            ListDanhMucControl1.Visible = true;
            AddNewDanhMucControl1.Visible = true;

            //UpdatePanelListLoaiDanhMucControl.Update();
            //UpdatePanelAddNewDanhMucControl.Update();
        }

        void ListLoaiDanhMucControl1_ReloadData(object sender, OneParameterEventAgrs<string> e)
        {
            switch (e.myType)
            {
                case "AddNew":
                    AddNewLoaiDanhMucControl1.Show(ListLoaiDanhMucControl1.ObjecOnDelaga);
                    SetVisibleFalseALL();
                    ListLoaiDanhMucControl1.Visible = true;
                    AddNewLoaiDanhMucControl1.Visible = true;
                    //UpdatePanelAddNewLoaiDanhMucControl.Update();
                    //UpdatePanelListDanhMucControl.Update();
                    break;
                case "DetailCommand":
                    ListDanhMucControl1.Show(ListLoaiDanhMucControl1.ObjecOnDelaga);
                    SetVisibleFalseALL();
                    ListLoaiDanhMucControl1.Visible = true;
                    ListDanhMucControl1.Visible = true;
                    //UpdatePanelListDanhMucControl.Update();
                    //UpdatePanelAddNewLoaiDanhMucControl.Update();
                    break;
            }
        }
        private void SetVisibleFalseALL()
        {
            AddNewLoaiDanhMucControl1.Visible = false;
            AddNewDanhMucControl1.Visible = false;
            ListLoaiDanhMucControl1.Visible = false;
            ListDanhMucControl1.Visible = false;
        }
    }
}